package com.cskaoyan.dbutils;

import com.cskaoyan.connectionpool.opensource.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;

import java.sql.Connection;
import java.sql.SQLException;

/**
 * 创建日期: 2022/08/29 09:56
 *
 * @author ciggar
 *
 * QueryRunner
 *
 * 执行Update方法，不传Connection对象
 */
public class Demo3 {

    public static void main(String[] args) throws SQLException {


        // 传入数据库连接池
        QueryRunner queryRunner = new QueryRunner(DruidUtils.getDataSource());


        int affectedRows = queryRunner.update("update user set username = ?,nickname=? where id = ?",
                "林冲","豹子头","1004");


        System.out.println("affectedRows:" + affectedRows);


    }


}
